Hello and welcome back to the costs.
So in the last session we learned a lot about different data types and now we are continuing to increase
our toolset and get familiar with operators.
So operators allow us to have interactions between objects.
And in this sense we are getting closer to work on real world problems where we have many interactions
and relationships between objects.
In this session we also get familiar with the special data type of billions.
But for now let's start with them.
Arithmetic operators and yeah actually we already know most of them.
And this part here is the smallest the repetition classify we have so you are right about we have a
equals five B equals two and C equals seven.
And we know that began at two integers so A plus B gives a seven.
You can subtract two integers A minus.
Big ifs.
Three you can multiply eight times B gives us 10.
We can divide a divided by B.
Give us 2.5.
So this is a float object and that's another operation called flaw divide.
So it's.
So here we have two to slash all sexually and the fifth run the cell.
So we have a division here and then yeah actually v v rounded down to the next integer in this case
too and we can also have an exponential.
So a to the power of B gives us 25 and that's an operator model law.
Let's run this out here model August.
The remainder of the division a divided by B.
So let's check a divided by being five two divided by two is two and the remainder is one.
All right so let's head to comparison operators and ask before we assign some arrivals and then what
we are doing we are comparing is a equal to B and you have to be careful here it's a double equal sign.
So a single equals sign would actually assign a equals b about a double equal sign checks if A is equal
B and then returns true if is equal B.
And the returns are false if A is not equal B.
So here we have a is 5 B is 2.
So I would expect that we get on false
now next operation a exclamation mark equal B.
So what this operation does.
It actually checks if A is not equal to be so.
Yeah we know here a is not equal to be so it should give us a true.
Then we have the less sine.
So the less sine checks if A is smaller or less than B.
And we would expect the false here and we have the greater than sign and this checks of A is greater
than B I would assume that we get a true and we can also do more complex operations so we can check
if A plus B is less are equal than C.
So A plus B seven C is seven.
So C is less or equal than seven.
That's true.
So now before the operators they give us true or false s as a result of the comparison and true and
false they are both.
Yeah especially the data types called boolean.
And if you check the type of truth it gives us bool for boolean and we can also check about the true
stands numerically far by transforming true into an integer and true all A stands for one and we can
also transform faults into an integer and force always stands for zero.
And we can do it the other way around.
We can transform an integer into a pool object and let's try it with one so this gives us a true.
And also if you transform life into beauty this gives us also a true.
And the rules.
Each integer or float.
That is not equal to zero gives us the true.
If we transform it into a pool soon the only number or integer which gives us the false if we transform
it into pool is zero actually.
And you can also check the mathematical behavior of true and false by applying arithmetic operations
so we can calculate five times true true stands for one.
So we would expect five.
And that's true.
And we can also make an addition so five plus true guess six.
And let's try the same with false or five times false returns zero.
And we can also assign a brilliant object to our rivals so that's known no problem.
So five equals two.
That's false and we assign false to the variety the empty is now stands for False and we can also then
make operations on the.
So five times the D stands for False gives us zero.
So earlier when we learned about lists we learned that in a list we can actually start each data table
object.
Yeah we can think of and this holds also true for a boolean.
We can put a boolean into a list.
So now let's execute the list L so on the list l this a integer 1 2 integers that's a string cat that's
a float object at one point five and that's a boolean object true.
All right so let's go ahead with a logical operators.
So in the first one this and and this is the so-called logical end and was in logical end does it checks
if all conditions are true and only if conditions are true then we get a true or so true and true gifts
less true if both are true.
So that's easy here in that case.
Now it's getting a bit more difficult so we have two conditions five greater than two and seven greater
than two.
So we know both conditions are true then we should get a true here and in most cases the end sign works
in the same way so there are some some minor cases that doesn't work but I don't want to go into detail
here.
So to introduce true.
And also 5 greater than 2 and 7 greater than to give us 2.
So let's go ahead with true and false.
So we only get a true if both statements are true but obviously false is not true.
Now we have 5 greater than 2 and 7 less than 2.
So obviously 7 less than 2 is false and not all conditions are true.
So we should get a false and also false and false will give us a false and five.
Less than two is false and seven less than two is also false so we should get a false okay.
Let's continue with the logical are so logical are checks the statements and it gives us a true if at
least one conditional statement is true.
So if you have true are true that gives us the true costs at least one condition is true.
So yeah both conditions true alternatively you can use the pipe symbol for or so on.
Yeah the very most cases this also works so depends on whether your keyboard is uh American English
or European one.
You can find the pipe symbol and also with the type symbol true or true.
Gives us true and also five greater to or seventh grader to guess as true true or false gives us also
a true because at least one condition is true and this is also the same as 5 greater than 2 are 7 less
to us or 5 greater 2 is a true statement so this gives us true and false and false gives us a false
because no no statement is true here and last but not least we have the not logical operator so the
not logical operator simply reverses true and false.
So if we have actually false and say Not false is true.
So that's quite easy and not true as false and last but not least now we have a bit more complicated
example.
We start here with this bracket 5 greater 2 is true not true is false false or false gives false and
then here outside the record is not so not false should give us true.
So that's it for the upper right us.
And I hope you enjoyed it and you will see us in the next session.
Uh about conditional statements if elif X and Y.
So seen by.